﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using KMFrame.Core;

namespace SzCourt.WebSite.manager
{
    public partial class tongji : System.Web.UI.Page
    {
        public int PageIndex = 1;
        public int PageSize = 20;
        public int TotalPage = 1;
        public string Keyword = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!AdminSession.SessionBox.CheckUserSession())
            {
                Response.Redirect("/manager/login.aspx");
            }
            if (!this.IsPostBack)
            {
                getList();
            }

        }

        private void getList()
        {
            this.PageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);
            string siteCol = string.IsNullOrEmpty(Request.QueryString["SiteCol"]) ? "" : Request.QueryString["SiteCol"];
            string deptName=string.IsNullOrEmpty(Request.QueryString["Dept"]) ? "" : Request.QueryString["Dept"];
            string userName = string.IsNullOrEmpty(Request.QueryString["User"]) ? "" : Request.QueryString["User"];
            string strBeginDate = string.IsNullOrEmpty(Request.QueryString["BeginDate"]) ? "" : Request.QueryString["BeginDate"];
            string strEndDate = string.IsNullOrEmpty(Request.QueryString["EndDate"]) ? "" : Request.QueryString["EndDate"];

            this.txtSiteCol.Value = siteCol;
            this.txtDept.Value = deptName;
            this.txtUser.Value = userName;
            this.txtBeginDate.Value = strBeginDate;
            this.txtEndDate.Value = strEndDate;
            DateTime beginDate = DateTime.MinValue;
            DateTime endDate = DateTime.MinValue;
            if (!string.IsNullOrEmpty(strBeginDate))
            {
                beginDate = DateTime.Parse(strBeginDate);
            }
            if (!string.IsNullOrEmpty(strEndDate))
            {
                endDate = DateTime.Parse(strEndDate);
            }
            PageParam param=new PageParam();
            param.PageIndex = PageIndex;
            param.PageSize = PageSize;
            UseStatistics bll = new UseStatistics();
            PageResult result = (PageResult)bll.GetStatisticsList(param, siteCol, deptName, userName, beginDate, endDate);

           if (result != null)
            {
                this.rptDataList.DataSource = result.ResultList;
                this.rptDataList.DataBind();

                this.pager1.RecordCount = result.TotalCount; //实际的库存数量
                this.pager1.TotalPage = result.PageCount;
                this.pager1.PageIndex = this.PageIndex;
                this.pager1.PageSize = this.PageSize;
                this.pager1.LinkUrl = "/manager/tongji.aspx?PageIndex=" + this.PageIndex.ToString() + "&Dept=" + deptName + "&User=" + userName + "&BeginDate=" + strBeginDate + "&EndDate=" + strEndDate + "&SiteCol=" + siteCol;
                this.pager1.IsResult = false;
            }
           
        }
    }
}